﻿using System;
using System.Text;
using System.IO;
using UnityEngine;

namespace DashFire
{
  public enum ResUpdateError
  {
    None = 0,

    Create_Assetbundle_Error = 1,
    ClientResVersion_Save_Error,
    Network_Error,

    // MD5
    RequestServer_MD5_Error = 10,

    // RequestServerVersion
    RequestServerVersion_WWW_Error = 100,
    RequestServerVersion_Byte_Error,
    RequestServerVersion_Save_Error,
    RequestServerVersion_Load_Error,

    // RequestClientVersion
    RequestClientVersion_WWW_Error = 200,
    RequestClientVersion_Byte_Error,
    RequestClientVersion_Load_Error,

    // RequestResCache
    RequestResCache_WWW_Error = 300,
    RequestResCache_Byte_Error,
    RequestResCache_Save_Error,
    LoadResCache_WWW_Error,
    LoadResCache_Byte_Error,
    LoadResCache_Save_Exception,
    LoadResCache_Assetbundle_Error,
    LoadResCache_Assetbundle_Load_Error,
    LoadResCache_Collect_Exception,

    // ResDownloader
    ResDownloader_Asset_Error = 400,
    ResDownloader_WWW_Error,
    ResDownloader_Save_Error,

    // ResLevelLoader
    ResLevelLoader_ResVersion_Error = 500,
    ResLevelLoader_Extract_Error,
    ResLevelLoader_Cache_Error,

    // ResSheetLoader
    RequestResSheet_WWW_Error = 600,
    RequestResSheet_Byte_Error,
    RequestResSheet_Save_Error,
    LoadResSheet_WWW_Error,
    LoadResSheet_Byte_Error,
    LoadResSheet_Save_Error,
    LoadResSheet_Assetbundle_Error,
    LoadResSheet_Extract_Error,

    // ResVersionLoader
    RequestResVersion_WWW_Error = 700,
    RequestResVersion_Byte_Error,
    RequestResVersion_Save_Error,
    LoadResVersion_WWW_Error,
    LoadResVersion_Byte_Error,
    LoadResVersion_Save_Error,
    LoadResVersion_Assetbundle_Error,
    LoadResVersion_Assetbundle_Load_Error,
    LoadResVersion_AsssetEx_Mgr_Error,
    LoadClientResVersion_WWW_Error,
    LoadClientResVersion_Byte_Error,
    LoadClientResVersion_Save_Error,

    // ResZipLoader
    ResZipLoader_WWW_Error = 800,
    ResZipLoader_Save_Error,
    ResZipLoader_Asset_Error,

    // ServerConfig
    RequestServerList_WWW_Error = 900,
    RequestServerList_Byte_Error,
    RequestServerList_Save_Error,

    // NoticeConfig
    RequestNoticeConfig_WWW_Error = 900,
    RequestNoticeConfig_Byte_Error,
    RequestNoticeConfig_Save_Error,

    // GameConfig
    RequestGameConfig_WWW_Error = 1000,
    RequestGameConfig_Byte_Error,
    RequestGameConfig_Save_Error,

    // ResPackage
    RequestResPackage_WWW_Error = 1100,
    RequestResPackage_Byte_Error,
    RequestResPackage_Save_Error,

    // ChannelConfig
    RequestChannelConfig_WWW_Error = 1200,
    RequestChannelConfig_Byte_Error,
    RequestChannelConfig_Save_Error,

    // ResInner
    RequestInnerResVersion_WWW_Error = 1300,
    RequestInnerResVersion_Byte_Error,
    RequestInnerResVersion_Save_Error,
    LoadInnerResVersion_WWW_Error,
    LoadInnerResVersion_Byte_Error,
    LoadInnerResVersion_Save_Error,
    LoadInnerResVersion_Assetbundle_Error,
    LoadInnerResVersion_Extract_Error,
    LoadInnerResVersion_Load_Error,
  }

  public enum ResPathType
  {
    Remote,
    Buildin,
    Cache,
  }
  public enum ResFileType
  {
    ResVersion,
    ResInner,
  }
  public class ResUpdateConfig
  {
    #region Define
    public const string s_ClientVersionFile = "ClientVersion.txt";
    public const string s_ServerVersionFile = "ServerVersion.txt";

    public const string s_ResVersionZip = "ResVersion.ab";
    public const string s_ResVersionFile = "ResVersion_ab.txt";

    public const string s_ResSheetZipFormat = "sheet{0}.ab";
    public const string s_ResSheetZipName = "sheet";

    public const string s_ResVersionClientFile = "ClientResVersion_ab.txt";
    public const string s_ResVersionClientFormat = "{0}	{1}	{2}	{3}	{4}	{5}";
    public const string s_ResVersionClientHeader = "AssetBundleName	AssetName	AssetShortName	MD5	Size	Dependency";

    public const string s_ResBuildInPath = "ResFile/";
    public const string s_ResCachePath = "ResFile/";
    public const string s_ResSheetFile = "sheet.txt";
    public const string s_ResSheetCachePath = "DataFile/";

    public const string s_ResPackageFile = "ResPackage_ab.txt";

    public const string s_ResInnerFile = "ResVersion_ab.txt";
    #endregion

    public static string[] s_ConfigSplit = new string[] { ";", "|", };
    public const string s_VersionInfoFormat = "Version: {0}.{1}.{2} ({3})";
    public static int s_AsyncCoroutineMax = 2;
    public const int s_ReconnectSkipNumMax = 3;
    public const string s_LoadSceneName = "Loading";
    public const int s_PreloadFrameNumMax = 10;
  }
}
